package com.panda.system.controller;

import com.panda.common.annotation.Log;
import com.panda.common.core.controller.BaseController;
import com.panda.common.core.domain.AjaxResult;
import com.panda.common.core.page.TableDataInfo;
import com.panda.common.enums.BusinessType;
import com.panda.common.utils.poi.ExcelUtil;
import com.panda.system.domain.TPandaTaskUser;
import com.panda.system.dto.TaskAdjust;
import com.panda.system.service.ITPandaTaskUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 操作任务Controller
 * 
 * @author panda
 * @date 2021-03-04
 */
@RestController
@RequestMapping("/system/operationTask")
public class TPandaTaskUserController extends BaseController
{
    @Autowired
    private ITPandaTaskUserService tPandaTaskUserService;

    /**
     * 查询操作任务列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TPandaTaskUser tPandaTaskUser)
    {
        startPage();
        List<TPandaTaskUser> list = tPandaTaskUserService.selectTPandaTaskUserList(tPandaTaskUser);
        return getDataTable(list);
    }

    /**
     * 导出操作任务列表
     */
    @Log(title = "操作任务", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TPandaTaskUser tPandaTaskUser)
    {
        List<TPandaTaskUser> list = tPandaTaskUserService.selectTPandaTaskUserList(tPandaTaskUser);
        ExcelUtil<TPandaTaskUser> util = new ExcelUtil<TPandaTaskUser>(TPandaTaskUser.class);
        return util.exportExcel(list, "operationTask");
    }

    /**
     * 获取操作任务详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tPandaTaskUserService.selectTPandaTaskUserById(id));
    }

    /**
     * 新增操作任务
     */
    @Log(title = "操作任务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TPandaTaskUser tPandaTaskUser)
    {
        return toAjax(tPandaTaskUserService.insertTPandaTaskUser(tPandaTaskUser));
    }

    /**
     * 修改操作任务
     */
    @Log(title = "操作任务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TPandaTaskUser tPandaTaskUser)
    {
        return toAjax(tPandaTaskUserService.updateTPandaTaskUser(tPandaTaskUser));
    }

    /**
     * 删除操作任务
     */
    @Log(title = "操作任务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tPandaTaskUserService.deleteTPandaTaskUserByIds(ids));
    }

    @PostMapping("/taskAdjust")
    public AjaxResult taskAdjust(@RequestBody TaskAdjust taskAdjust){
        return tPandaTaskUserService.taskAdjust(taskAdjust);
    }
}
